home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / include / stdio.h < prev    next >
C/C++ Source or Header  |  1990-07-23  |  5KB  |  176 lines

  1. /* The <stdio.h> header is used by the I/O routines. */
  2.  
  3. #ifndef _STDIO_H
  4. #define _STDIO_H
  5.  
  6. #ifdef NULL
  7. #undef NULL
  8. #endif
  9.  
  10. #define BUFSIZ  1024
  11. #define NFILES  20
  12. #define NULL       0
  13. #define EOF     (-1)
  14. #define CMASK   0377
  15.  
  16. #define READMODE     1
  17. #define WRITEMODE    2
  18. #define UNBUFF       4
  19. #define _EOF         8
  20. #define _ERR        16
  21. #define IOMYBUF     32
  22. #define PERPRINTF   64
  23. #define STRINGS    128
  24.  
  25. #ifndef FILE
  26.  
  27. extern struct _io_buf {
  28.     int     _fd;
  29.     int     _count;
  30.     int     _flags;
  31.     char   *_buf;
  32.     char   *_ptr;
  33. }  *_io_table[NFILES];
  34.  
  35.  
  36. #endif    /* FILE */
  37.  
  38. #define FILE struct _io_buf
  39.  
  40.  
  41. #define stdin  (_io_table[0])    
  42. #define stdout     (_io_table[1])
  43. #define stderr     (_io_table[2])
  44.  
  45. /* -------------- Prototypes copied from Earl Chew's stdio -----------------*/
  46.  
  47. #include <ansi.h>
  48.  
  49. #if _ANSI
  50. #  define __STDIO_P__(__x) __x
  51. #  define __STDIO_VA__ ,...
  52. #else
  53. #  define __STDIO_P__(__x) ()
  54. #  define __STDIO_VA__
  55. #endif
  56.  
  57. #ifndef _SIZE_T
  58. #define _SIZE_T
  59. typedef unsigned size_t;
  60. #endif
  61.  
  62. #define __fpos_t long
  63. #define __STDIO_VA_LIST__    void *
  64.  
  65. /* ANSI Stdio Requirements */
  66.  
  67. int    getc        __STDIO_P__((FILE *));
  68. int    getchar        __STDIO_P__((void));
  69. int    putc        __STDIO_P__((int, FILE *));
  70. int    putchar        __STDIO_P__((int));
  71. int    feof        __STDIO_P__((FILE *));
  72. int    ferror        __STDIO_P__((FILE *));
  73. void    clearerr    __STDIO_P__((FILE *));
  74.  
  75. FILE     *fopen        __STDIO_P__((const char *, const char *));
  76. FILE    *freopen    __STDIO_P__((const char *, const char *, FILE *));
  77. int    fflush        __STDIO_P__((FILE *));
  78. int    fclose        __STDIO_P__((FILE *));
  79.  
  80. int    fgetpos        __STDIO_P__((FILE *, __fpos_t *));
  81. int    fsetpos        __STDIO_P__((FILE *, __fpos_t *));
  82. long    ftell        __STDIO_P__((FILE *));
  83. int    fseek        __STDIO_P__((FILE *, long, int));
  84. void    rewind        __STDIO_P__((FILE *));
  85.  
  86. int    fgetc        __STDIO_P__((FILE *));
  87. int    fputc        __STDIO_P__((int, FILE *));
  88. size_t    fread        __STDIO_P__((void *, size_t, size_t, FILE *));
  89. size_t    fwrite        __STDIO_P__((const void *, size_t, size_t, FILE *));
  90.  
  91. int    getw        __STDIO_P__((FILE *));
  92. int    putw        __STDIO_P__((int, FILE *));
  93. char    *gets        __STDIO_P__((char *));
  94. char    *fgets        __STDIO_P__((char *, int, FILE *));
  95. int    puts        __STDIO_P__((const char *));
  96. int    fputs        __STDIO_P__((const char *, FILE *));
  97.  
  98. int    ungetc        __STDIO_P__((int, FILE *));
  99.  
  100. /* WRONG */
  101. void    printf        __STDIO_P__((const char * __STDIO_VA__));
  102. /* WRONG */
  103. void    fprintf        __STDIO_P__((FILE *, const char * __STDIO_VA__));
  104. /* WRONG */
  105. char    *sprintf    __STDIO_P__((char *, const char * __STDIO_VA__));
  106. int    vprintf        __STDIO_P__((const char *, __STDIO_VA_LIST__));
  107. int    vfprintf    __STDIO_P__((FILE *, const char *, __STDIO_VA_LIST__));
  108. /* WRONG */
  109. char     *vsprintf    __STDIO_P__((char *, const char *, __STDIO_VA_LIST__));
  110. int    scanf        __STDIO_P__((char *nonconstfmt __STDIO_VA__));
  111. int    fscanf        __STDIO_P__((FILE *, char *nonconstfmt __STDIO_VA__));
  112. int    sscanf        __STDIO_P__((char *nonconststr, char *nonconstfmt __STDIO_VA__));
  113.  
  114. void    setbuf        __STDIO_P__((FILE *, char *));
  115. int    setvbuf        __STDIO_P__((FILE *, char *, int, size_t));
  116.  
  117. int    rename        __STDIO_P__((const char *, const char *));
  118. int    remove        __STDIO_P__((const char *));
  119.  
  120. void    perror        __STDIO_P__((const char *));
  121.  
  122. char *    tmpnam        __STDIO_P__((char *));
  123. FILE *    tmpfile        __STDIO_P__((void));
  124.  
  125. /* Posix Definitions */
  126. int    unlink        __STDIO_P__((const char *));
  127.  
  128. char *    ctermid        __STDIO_P__((char *s));
  129.  
  130. char *    cuserid        __STDIO_P__((char *s));
  131.  
  132. FILE    *fdopen        __STDIO_P__((int, const char *));
  133.  
  134. int    fileno        __STDIO_P__((FILE *));
  135.  
  136. /* Local Definitions */
  137. extern _PROTOTYPE( void (*__cleanup), (void)                );
  138. _PROTOTYPE( void _doprintf, (FILE *iop, const char *fmt,
  139.                  __STDIO_VA_LIST__)                );
  140. _PROTOTYPE( int _doscanf, (int code, char *funcarg, char *nonconstfmt,
  141.                  __STDIO_VA_LIST__)                );
  142. _PROTOTYPE( void prints, (const char *fmt __STDIO_VA__)            );
  143.  
  144. /* ---------------------- End of Earl's prototypes --------------------------*/
  145.  
  146. #define getchar()         getc(stdin)
  147. #define putchar(c)         putc(c,stdout)
  148. #define getc(f)            fgetc(f)
  149. #define putc(c,f)        fputc(c,f)
  150. #define feof(p)         (((p)->_flags & _EOF) != 0)
  151. #define ferror(p)         (((p)->_flags & _ERR) != 0)
  152. #define clearerr(p)         ((p)->_flags &= ~(_ERR))
  153. #define fileno(p)         ((p)->_fd)
  154. #define rewind(f)        fseek(f, 0L, 0)
  155. #define testflag(p,x)        ((p)->_flags & (x))
  156.  
  157. /* If you want a stream to be flushed after each printf use:
  158.  * 
  159.  *    perprintf(stream);
  160.  *
  161.  * If you want to stop with this kind of buffering use:
  162.  *
  163.  *    noperprintf(stream);
  164.  */
  165.  
  166. #define noperprintf(p)        ((p)->_flags &= ~PERPRINTF)
  167. #define perprintf(p)        ((p)->_flags |= PERPRINTF)
  168.  
  169. extern FILE    *fopen();
  170. extern FILE    *freopen();
  171. extern long    ftell();
  172. extern char    *fgets();
  173. extern char    *gets();
  174.  
  175. #endif /* _STDIO_H */
  176.